<template>
	<view class="content fofa poRel">
		<tabnav title="个人信息" :col="back"></tabnav>
		<view style="height: 40rpx;"></view>
		<view class="wid87 mar bacFFF borRad20 foSi30" style="">
			<view class="wid90 mar dis disAl disJuB" style="height: 100rpx;"
				@click="tiaozhuan('/pages/wode/details/detailsName')">
				<view>姓名</view>
				<view class="dis disAl">
					<view class="mar-right10" style="color: #5E5E5E;">{{inuse_userinfo.nickname}}</view>
					<uni-icons size="20" color="#5E5E5E" type="right"></uni-icons>
				</view>
			</view>
			<view class="xia wid100"></view>
			<view class="wid90 mar dis disAl disJuB" style="height: 100rpx;">
				<view>实名状态</view>
				<view class="dis disAl" @click="go_real">
					<view style="color: #5E5E5E;">{{inuse_userinfo.is_auth == 1 ? '已实名' : '去实名'}}</view>
					<uni-icons size="20" color="#5E5E5E" type="right" v-if="inuse_userinfo.is_auth == 0"></uni-icons>
				</view>
			</view>
			<view class="xia wid100"></view>
			<view class="wid90 mar dis disAl disJuB" style="height: 100rpx;">
				<view>证件类型</view>
				<view style="color: #5E5E5E;">居民身份证</view>
			</view>
			<view class="xia wid100"></view>
			<view class="wid90 mar dis disAl disJuB" style="height: 100rpx;">
				<view>证件号</view>
				<view style="color: #5E5E5E;">{{inuse_userinfo.id_number}}</view>
			</view>
			<view class="xia wid100"></view>
			<view class="wid90 mar dis disAl disJuB" style="height: 100rpx;"
				@click="tiaozhuan('/pages/wode/details/detailsTel')">
				<view>手机号</view>
				<view class="dis disAl">
					<view class="mar-right10" style="color: #5E5E5E;">{{inuse_userinfo.mobile}}</view>
					<uni-icons size="20" color="#5E5E5E" type="right"></uni-icons>
				</view>
			</view>
			<view class="xia wid100"></view>
			<view class="wid90 mar dis disAl disJuB" style="height: 100rpx;"
				@click="tiaozhuan('/pages/wode/details/detailsMailbox')">
				<view>邮箱地址</view>
				<view class="dis disAl">
					<view class="mar-right10" style="color: #5E5E5E;">
						{{!inuse_userinfo.email ? '未设置' : inuse_userinfo.email}}</view>
					<uni-icons size="20" color="#5E5E5E" type="right"></uni-icons>
				</view>
			</view>
		</view>
		<view class="wid87 mar bacFFF borRad20 mar-top30">
			<view class="wid90 mar dis disAl disJuB" style="height: 100rpx;"
				@click="tiaozhuan('/pages/wode/details/settings')">
				<view>更多设置</view>
				<uni-icons size="20" color="#5E5E5E" type="right"></uni-icons>
			</view>
		</view>
		<view class="wid100 dis disAl disJuC poAbs" :style="{'padding-bottom': paddingBottomHeight + 'rpx'}" style="bottom: 40rpx;" @click="outlogin">
			<view class="dis disAl disJuC coFFF hei80 foSi35 borRad20 wid90 mar" :style="'background-color: '+back+';'">退出登录</view>
		</view>
	</view>
</template>

<script>
	import tabnav from "../../common/tabnav/tabnav.vue"
	export default {
		components: {
			tabnav,
		},
		data() {
			return {
				paddingBottomHeight: 0,
				back: uni.getStorageSync('back'),
				backTwo: uni.getStorageSync('backTwo'),
				inuse_userinfo: {}
			}
		},
		onShow() {
			this.getdata()
		},
		created() {
			let that = this;
			uni.getSystemInfo({
				success: function (res) {
					let model = ['X', 'XR', 'XS', '11', '12', '13', '14', '15'];
					model.forEach(item => {
						//适配iphoneX以上的底部，给tabbar一定高度的padding-bottom
						if(res.model.indexOf(item) != -1 && res.model.indexOf('iPhone') != -1) {
							that.paddingBottomHeight = 40;
						}
					})
				}
			});
		},
		methods: {
			getdata() {
				// 用户个人信息
				var that = this
				uni.showLoading({
					title: '加载中...'
				})
				uni.request({
					url: that.global.url + 'api/qianyu_dzq/applet_user_info',
					method: 'POST',
					header: {
						'site-id': that.global.site_id,
						'token': uni.getStorageSync('inuse_userinfo_token')
					},
					data: {},
					success(res) {
						let result = res.data
						if (result.code == 1) {
							that.inuse_userinfo = result.data
							var reg = /(\d{3})\d{4}(\d{4})/;
							that.inuse_userinfo.mobile = result.data.mobile.replace(reg, "$1****$2")
							uni.setStorageSync('wode_detail', result.data)
						} else {
							uni.showToast({
								title: result.msg,
								icon: 'error'
							})
						}
					},
					complete() {
						uni.hideLoading()
					}
				})
			},
			outlogin(){
				// 存用户信息
				uni.removeStorageSync('main_userinfo') // 主账号用户信息
				uni.removeStorageSync('main_userinfo_token') // 主账号token
				// 存使用中账号信息，由于刚刚登录所以使用中就是主账号，同步存
				uni.removeStorageSync('inuse_userinfo')   // 使用中的用户信息
				uni.removeStorageSync('inuse_userinfo_token') // 使用中的用户token
				uni.$emit('login_out',{msg:'更新用户信息重新获取数据'})
				uni.navigateBack()
			},
			// 去实名
			go_real(){
				if(this.inuse_userinfo.is_auth == 0){
					uni.navigateTo({
						url:'/pages/wode/details/userauth'
					})
				}
			},
			tiaozhuan(url) {
				uni.navigateTo({
					url: url
				});
			},
		}
	}
</script>

<style>
	.content {
		height: 100vh;
		background-color: #F4F3F3;
	}

	.foSi28 {
		font-size: 28rpx;
	}

	.xia {
		height: 1rpx;
		background: #e7e7e7;
	}
</style>